using FineCollection.Intf;
using NUnit.Framework;



namespace FineCollection.Cont
{
    [TestFixture]
    public class ArrMap_test
    {
        
        [Test]
        public void test_Include_MakingHashTable()
        {
            ArrMap<string,string> am = new ArrMap<string, string>();

            am.Include("A", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
            am.Include("B", "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
            am.Include("C", "ccccccccccccccccccccccccccccccccc");
            am.Include("D", "ddddddddddddddddddddddddddddddddd");
            am.Include("E", "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
            am.Include("F", "fffffffffffffffffffffffffffffffff");
            am.Include("G", "ggggggggggggggggggggggggggggggggg");
            am.Include("H", "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
            am.Include("I", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
            am.Include("J", "jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
            am.Include("K", "kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
            am.Include("L", "lllllllllllllllllllllllllllllllll");

            // they should not throw exceptions
        }
        

        [Test]
        public void test_FindKey_Small()
        {
            ArrMap<string, string> am = new ArrMap<string, string>();

            am.Include("A", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
            am.Include("B", "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
            am.Include("C", "ccccccccccccccccccccccccccccccccc");

            Assert.AreEqual(1, am.FindKey("A"));
            Assert.AreEqual(2, am.FindKey("B"));
            Assert.AreEqual(3, am.FindKey("C"));

            Assert.AreEqual(int.MinValue, am.FindKey("X"));
        }


        [Test]
        public void test_FindKey_Big()
        {
            ArrMap<string, string> am = new ArrMap<string, string>();

            am.Include("A", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
            am.Include("B", "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
            am.Include("C", "ccccccccccccccccccccccccccccccccc");
            am.Include("D", "ddddddddddddddddddddddddddddddddd");
            am.Include("E", "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
            am.Include("F", "fffffffffffffffffffffffffffffffff");
            am.Include("G", "ggggggggggggggggggggggggggggggggg");
            am.Include("H", "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
            am.Include("I", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
            am.Include("J", "jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
            am.Include("K", "kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
            am.Include("L", "lllllllllllllllllllllllllllllllll");

            Assert.AreEqual(1, am.FindKey("A"));
            Assert.AreEqual(2, am.FindKey("B"));
            Assert.AreEqual(3, am.FindKey("C"));
            Assert.AreEqual(10, am.FindKey("J"));
            Assert.AreEqual(11, am.FindKey("K"));
            Assert.AreEqual(12, am.FindKey("L"));

            Assert.AreEqual(int.MinValue, am.FindKey("X"));
        }


        [Test]
        public void test_Exclude_FromBigArray_KeyValuesAreCorrect()
        {
            ArrMap<string, string> am = new ArrMap<string, string>();

            am.Include("A", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
            am.Include("B", "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
            am.Include("C", "ccccccccccccccccccccccccccccccccc");
            am.Include("D", "ddddddddddddddddddddddddddddddddd");
            am.Include("E", "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
            am.Include("F", "fffffffffffffffffffffffffffffffff");
            am.Include("G", "ggggggggggggggggggggggggggggggggg");
            am.Include("H", "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
            am.Include("I", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
            am.Include("J", "jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
            am.Include("K", "kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
            am.Include("L", "lllllllllllllllllllllllllllllllll");

            am.Exclude("B");
            am.Exclude("D");
            am.Exclude("F");
            am.Exclude("H");
            am.Exclude("J");
            am.Exclude("L");

            Assert.AreEqual("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", am["A"]);
            Assert.AreEqual("ccccccccccccccccccccccccccccccccc", am["C"]);
            Assert.AreEqual("eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", am["E"]);
            Assert.AreEqual("ggggggggggggggggggggggggggggggggg", am["G"]);
            Assert.AreEqual("iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii", am["I"]);
            Assert.AreEqual("kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk", am["K"]);
        }


        [Test]
        public void test_Exclude_FromBigArray_IndicesAreCorrect()
        {
            ArrMap<string, string> am = new ArrMap<string, string>();

            am.Include("A", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
            am.Include("B", "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
            am.Include("C", "ccccccccccccccccccccccccccccccccc");
            am.Include("D", "ddddddddddddddddddddddddddddddddd");
            am.Include("E", "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
            am.Include("F", "fffffffffffffffffffffffffffffffff");
            am.Include("G", "ggggggggggggggggggggggggggggggggg");
            am.Include("H", "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
            am.Include("I", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
            am.Include("J", "jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
            am.Include("K", "kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
            am.Include("L", "lllllllllllllllllllllllllllllllll");

            am.Exclude("B");
            am.Exclude("D");
            am.Exclude("F");
            am.Exclude("H");
            am.Exclude("J");
            am.Exclude("L");

            Assert.AreEqual("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", am[1].Value);
            Assert.AreEqual("ccccccccccccccccccccccccccccccccc", am[2].Value);
            Assert.AreEqual("eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", am[3].Value);
            Assert.AreEqual("ggggggggggggggggggggggggggggggggg", am[4].Value);
            Assert.AreEqual("iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii", am[5].Value);
            Assert.AreEqual("kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk", am[6].Value);
        }

    }
}